import { Injectable } from '@angular/core';
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { AppSettings } from '../../shared/config/app-settings';
import { Observable } from 'rxjs/internal/Observable';

@Injectable({
  providedIn: 'root'
})
export class AgentService {

  constructor(private httpClient: HttpClient) { }

  ngOnInit(): void {
    //Called after the constructor, initializing input properties, and the first call to ngOnChanges.
    //Add 'implements OnInit' to the class.
    this.loadMySalesRecords();
  }

  loadMySalesRecords(): Observable<any> {
    return this.httpClient.get<Array<any>>(`${AppSettings.mock_base}/agent/my-sales-record.json`,{
      withCredentials: true,
      params: new HttpParams().set('mock','true'),
      headers: new HttpHeaders().set('Content-Type','application/json')
    });
  }

}
